/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
 */

package app.controllers.customer;

import app.models.member.Member;
import app.models.member.MemberIntegralRecord;
import com.github.sog.controller.BasicController;
import com.github.sog.controller.datatables.core.DatatablesCriterias;
import com.github.sog.libs.AppFunc;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

/**
 * <p>
 * .
 * </p>
 *
 * @author sagyf yang
 * @version 1.0 2014-05-15 22:48
 * @since JDK 1.6
 */
public class IntegralController extends BasicController {

    /**
     * The index route.
     */
    public void index() {
        final long member = getParaToLong(0, 0l);
        if (member > 0) {

            setAttr("member", Member.dao.findById(member));
        } else {
            renderNull();
        }
    }


    public void records() {
        final long member = getParaToLong(0, 0l);
        Member member_ = new Member();
        member_.set(AppFunc.TABLE_PK_COLUMN, member);
        final DatatablesCriterias criterias = getCriterias();
        Page<Record> recordPage = MemberIntegralRecord.dao.datatablesByMember(criterias, member_);

        renderDataTables(recordPage, criterias);
    }

}